#include "MemoryEvent.h"

namespace events {

void MemoryEvent::saveToStream(std::ostream &os) const {
	os.write(reinterpret_cast<const char*>(&_type), sizeof(_type));
	_size.saveToStream(os);
}

void MemoryEvent::readFromStream(std::istream &is) {
	is.read(reinterpret_cast<char*>(&_type), sizeof(_type));
	_size.readFromStream(is);
}

void MemoryEvent::writeDebugInfo(std::ostream &os) const {
	os << "MemoryEvent: type=";
	switch (_type) {
		case VallocCommit:
			os << "COMMIT";
			break;
		case VallocReserve:
			os << "RESERVE";
			break;
		case VallocReset:
			os << "RESET";
			break;
		default:
			os << "Unknown";
	};
	os << ", size=";
	_size.writeDebugInfo(os);
	os << '\n';
}


}  // end namespace
